<?php
	require "../dao/student_dao.php";
	
	session_start();
	$student = $_SESSION["student"];
	
    $student_marks = selectStumark();
	
	for($i=0;$i<count($student_marks);$i++){
		$student_mark = $student_marks[$i];
		$mark = null;
		$mark["mark_stuid"] = explode(',', $student_mark["mark_stuid"]);
		$mark_stuids = $mark["mark_stuid"];
		$mark["mark"] = explode(',', $student_mark["mark"]);
		$mark_marks = $mark["mark"];
		$mark["mark_tid"] = $student_mark["mark_tid"];
		
		for($p=0;$p<count($mark_stuids);$p++){
			for($q=0;$q<count($mark_marks);$q++){
				if($p == $q and $mark_stuids[$p] == $student["stuid"]){
					$teachers[] = selectSec_Tea($mark["mark_tid"]);
					$marks[] = $mark_marks[$q];
				}
			} 
		}
	}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" href="../css/select_infor.css" />
	<script src="../js/jquery-1.2.6.min.js"></script>
	<title>学生信息</title>
</head>
<body>
	<div id="wrap">
		<table id="tbl">
			<caption>
				<h3>学生成绩表</h3>
			</caption>
			<thead>
				<tr>
					<th>编号</th>
					<th>学生姓名</th>
					<th>学生学号</th>
					<th>学生学院</th>
					<th>学生年级</th>
					<th>学生班级</th>
					<th>课程名称</th>
					<th>分数</th>
					<th>授课老师</th>
					<th>老师学院</th>
				</tr>
			</thead>
			<tbody>
				<?php
					if(count($teachers)){
						for($i=0;$i<count($teachers);$i++){
							$teacher = $teachers[$i];
				?>
							<tr>
								<td><?=$i+1?></td>
								<td><?=$student["sname"]?></td>
								<td><?=$student["snumber"]?></td>
								<td><?=$student['collegename']?></td>
								<td><?=$student["gradename"]?></td>
								<td><?=$student["classname"]?></td>
								<td><?=$teacher["tcourse"]?>(<?=$teacher["tattr"]?>)</td>
								<td><?=$marks[$i]?></td>
								<td><?=$teacher["tname"]?></td>
								<td><?=$teacher["collegename"]?></td>
							</tr>
				<?php	
						}	
					}else{
				?>
						<script>
							alert("还没有老师输入成绩。。。")
						</script>
				<?php
					}
					
				?>
			</tbody>
		</table>
	</div>
</body>
</html>